package b.p.b;

import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.w;
import b.i.j.c;
import java.util.ArrayList;
import java.util.List;

/* compiled from: AdapterHelper */
public class a implements b.p.b.w.a {
    public c<b> a = new c(30);
    public final ArrayList<b> b = new ArrayList();
    public final ArrayList<b> c = new ArrayList();
    public final a d;
    public final w e;
    public int f = 0;

    /* compiled from: AdapterHelper */
    public interface a {
    }

    /* compiled from: AdapterHelper */
    public static class b {
        public int a;
        public int b;
        public Object c;
        public int d;

        public b(int i, int i2, int i3, Object obj) {
            this.a = i;
            this.b = i2;
            this.d = i3;
            this.c = obj;
        }

        public boolean equals(Object obj) {
            if (this == obj) {
                return true;
            }
            if (obj == null || b.class != obj.getClass()) {
                return false;
            }
            b bVar = (b) obj;
            int i = this.a;
            if (i != bVar.a) {
                return false;
            }
            if (i == 8 && Math.abs(this.d - this.b) == 1 && this.d == bVar.b && this.b == bVar.d) {
                return true;
            }
            if (this.d != bVar.d || this.b != bVar.b) {
                return false;
            }
            Object obj2 = this.c;
            if (obj2 != null) {
                if (!obj2.equals(bVar.c)) {
                    return false;
                }
            } else if (bVar.c != null) {
                return false;
            }
            return true;
        }

        public int hashCode() {
            return (((this.a * 31) + this.b) * 31) + this.d;
        }

        public String toString() {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(Integer.toHexString(System.identityHashCode(this)));
            stringBuilder.append("[");
            int i = this.a;
            String str = i != 1 ? i != 2 ? i != 4 ? i != 8 ? "??" : "mv" : "up" : "rm" : "add";
            stringBuilder.append(str);
            stringBuilder.append(",s:");
            stringBuilder.append(this.b);
            stringBuilder.append("c:");
            stringBuilder.append(this.d);
            stringBuilder.append(",p:");
            stringBuilder.append(this.c);
            stringBuilder.append("]");
            return stringBuilder.toString();
        }
    }

    public a(a aVar) {
        this.d = aVar;
        this.e = new w(this);
    }

    public final boolean a(int i) {
        int size = this.c.size();
        for (int i2 = 0; i2 < size; i2++) {
            b bVar = (b) this.c.get(i2);
            int i3 = bVar.a;
            if (i3 == 8) {
                if (f(bVar.d, i2 + 1) == i) {
                    return true;
                }
            } else if (i3 == 1) {
                i3 = bVar.b;
                int i4 = bVar.d + i3;
                while (i3 < i4) {
                    if (f(i3, i2 + 1) == i) {
                        return true;
                    }
                    i3++;
                }
                continue;
            } else {
                continue;
            }
        }
        return false;
    }

    public void b() {
        int size = this.c.size();
        for (int i = 0; i < size; i++) {
            ((b0) this.d).a((b) this.c.get(i));
        }
        l(this.c);
        this.f = 0;
    }

    public void c() {
        b();
        int size = this.b.size();
        for (int i = 0; i < size; i++) {
            b bVar = (b) this.b.get(i);
            int i2 = bVar.a;
            if (i2 == 1) {
                ((b0) this.d).a(bVar);
                ((b0) this.d).d(bVar.b, bVar.d);
            } else if (i2 == 2) {
                ((b0) this.d).a(bVar);
                a aVar = this.d;
                int i3 = bVar.b;
                int i4 = bVar.d;
                b0 b0Var = (b0) aVar;
                b0Var.a.S(i3, i4, true);
                RecyclerView recyclerView = b0Var.a;
                recyclerView.l0 = true;
                w wVar = recyclerView.i0;
                wVar.c += i4;
            } else if (i2 == 4) {
                ((b0) this.d).a(bVar);
                ((b0) this.d).c(bVar.b, bVar.d, bVar.c);
            } else if (i2 == 8) {
                ((b0) this.d).a(bVar);
                ((b0) this.d).e(bVar.b, bVar.d);
            }
        }
        l(this.b);
        this.f = 0;
    }

    public final void d(b bVar) {
        int i = bVar.a;
        if (i == 1 || i == 8) {
            throw new IllegalArgumentException("should not dispatch add or move for pre layout");
        }
        i = m(bVar.b, i);
        int i2 = bVar.b;
        int i3 = bVar.a;
        if (i3 == 2) {
            i3 = 0;
        } else if (i3 == 4) {
            i3 = 1;
        } else {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("op should be remove or update.");
            stringBuilder.append(bVar);
            throw new IllegalArgumentException(stringBuilder.toString());
        }
        int i4 = 1;
        for (int i5 = 1; i5 < bVar.d; i5++) {
            int m = m((i3 * i5) + bVar.b, bVar.a);
            int i6 = bVar.a;
            Object obj = (i6 == 2 ? m != i : !(i6 == 4 && m == i + 1)) ? null : 1;
            if (obj != null) {
                i4++;
            } else {
                b h = h(i6, i, i4, bVar.c);
                e(h, i2);
                k(h);
                if (bVar.a == 4) {
                    i2 += i4;
                }
                i = m;
                i4 = 1;
            }
        }
        Object obj2 = bVar.c;
        k(bVar);
        if (i4 > 0) {
            bVar = h(bVar.a, i, i4, obj2);
            e(bVar, i2);
            k(bVar);
        }
    }

    public void e(b bVar, int i) {
        ((b0) this.d).a(bVar);
        int i2 = bVar.a;
        if (i2 == 2) {
            a aVar = this.d;
            int i3 = bVar.d;
            b0 b0Var = (b0) aVar;
            b0Var.a.S(i, i3, true);
            RecyclerView recyclerView = b0Var.a;
            recyclerView.l0 = true;
            w wVar = recyclerView.i0;
            wVar.c += i3;
        } else if (i2 == 4) {
            ((b0) this.d).c(i, bVar.d, bVar.c);
        } else {
            throw new IllegalArgumentException("only remove and update ops can be dispatched in first pass");
        }
    }

    public int f(int i, int i2) {
        int size = this.c.size();
        while (i2 < size) {
            b bVar = (b) this.c.get(i2);
            int i3 = bVar.a;
            if (i3 == 8) {
                i3 = bVar.b;
                if (i3 == i) {
                    i = bVar.d;
                } else {
                    if (i3 < i) {
                        i--;
                    }
                    if (bVar.d <= i) {
                        i++;
                    }
                }
            } else {
                int i4 = bVar.b;
                if (i4 > i) {
                    continue;
                } else if (i3 == 2) {
                    int i5 = bVar.d;
                    if (i < i4 + i5) {
                        return -1;
                    }
                    i -= i5;
                } else if (i3 == 1) {
                    i += bVar.d;
                }
            }
            i2++;
        }
        return i;
    }

    public boolean g() {
        return this.b.size() > 0;
    }

    public b h(int i, int i2, int i3, Object obj) {
        b bVar = (b) this.a.a();
        if (bVar == null) {
            return new b(i, i2, i3, obj);
        }
        bVar.a = i;
        bVar.b = i2;
        bVar.d = i3;
        bVar.c = obj;
        return bVar;
    }

    public final void i(b bVar) {
        this.c.add(bVar);
        int i = bVar.a;
        if (i == 1) {
            ((b0) this.d).d(bVar.b, bVar.d);
        } else if (i == 2) {
            a aVar = this.d;
            b0 b0Var = (b0) aVar;
            b0Var.a.S(bVar.b, bVar.d, false);
            b0Var.a.l0 = true;
        } else if (i == 4) {
            ((b0) this.d).c(bVar.b, bVar.d, bVar.c);
        } else if (i == 8) {
            ((b0) this.d).e(bVar.b, bVar.d);
        } else {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append("Unknown update op type for ");
            stringBuilder.append(bVar);
            throw new IllegalArgumentException(stringBuilder.toString());
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:27:0x0070  */
    /* JADX WARNING: Removed duplicated region for block: B:26:0x006b  */
    /* JADX WARNING: Removed duplicated region for block: B:33:0x0092  */
    /* JADX WARNING: Removed duplicated region for block: B:32:0x008e  */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x009e  */
    /* JADX WARNING: Removed duplicated region for block: B:173:0x0009 A:{SYNTHETIC} */
    /* JADX WARNING: Removed duplicated region for block: B:37:0x00a3  */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x00d7  */
    /* JADX WARNING: Removed duplicated region for block: B:55:0x00d2  */
    /* JADX WARNING: Removed duplicated region for block: B:64:0x00ff  */
    /* JADX WARNING: Removed duplicated region for block: B:63:0x00fa  */
    /* JADX WARNING: Removed duplicated region for block: B:69:0x0127  */
    /* JADX WARNING: Removed duplicated region for block: B:68:0x0118  */
    /* JADX WARNING: Removed duplicated region for block: B:55:0x00d2  */
    /* JADX WARNING: Removed duplicated region for block: B:56:0x00d7  */
    /* JADX WARNING: Removed duplicated region for block: B:63:0x00fa  */
    /* JADX WARNING: Removed duplicated region for block: B:64:0x00ff  */
    /* JADX WARNING: Removed duplicated region for block: B:68:0x0118  */
    /* JADX WARNING: Removed duplicated region for block: B:69:0x0127  */
    public void j() {
        /*
        r16 = this;
        r0 = r16;
        r1 = r0.e;
        r2 = r0.b;
        java.util.Objects.requireNonNull(r1);
    L_0x0009:
        r3 = r2.size();
        r4 = 1;
        r3 = r3 - r4;
        r6 = 0;
    L_0x0010:
        r7 = 8;
        r8 = -1;
        if (r3 < 0) goto L_0x0026;
    L_0x0015:
        r9 = r2.get(r3);
        r9 = (b.p.b.a.b) r9;
        r9 = r9.a;
        if (r9 != r7) goto L_0x0022;
    L_0x001f:
        if (r6 == 0) goto L_0x0023;
    L_0x0021:
        goto L_0x0027;
    L_0x0022:
        r6 = 1;
    L_0x0023:
        r3 = r3 + -1;
        goto L_0x0010;
    L_0x0026:
        r3 = -1;
    L_0x0027:
        r6 = 0;
        r9 = 4;
        r10 = 2;
        if (r3 == r8) goto L_0x01c7;
    L_0x002c:
        r7 = r3 + 1;
        r11 = r2.get(r3);
        r11 = (b.p.b.a.b) r11;
        r12 = r2.get(r7);
        r12 = (b.p.b.a.b) r12;
        r13 = r12.a;
        if (r13 == r4) goto L_0x019d;
    L_0x003e:
        if (r13 == r10) goto L_0x00a8;
    L_0x0040:
        if (r13 == r9) goto L_0x0043;
    L_0x0042:
        goto L_0x0009;
    L_0x0043:
        r5 = r11.d;
        r8 = r12.b;
        if (r5 >= r8) goto L_0x004e;
    L_0x0049:
        r8 = r8 + -1;
        r12.b = r8;
        goto L_0x0064;
    L_0x004e:
        r10 = r12.d;
        r8 = r8 + r10;
        if (r5 >= r8) goto L_0x0064;
    L_0x0053:
        r10 = r10 + -1;
        r12.d = r10;
        r5 = r1.a;
        r8 = r11.b;
        r10 = r12.c;
        r5 = (b.p.b.a) r5;
        r4 = r5.h(r9, r8, r4, r10);
        goto L_0x0065;
    L_0x0064:
        r4 = r6;
    L_0x0065:
        r5 = r11.b;
        r8 = r12.b;
        if (r5 > r8) goto L_0x0070;
    L_0x006b:
        r8 = r8 + 1;
        r12.b = r8;
        goto L_0x0087;
    L_0x0070:
        r10 = r12.d;
        r8 = r8 + r10;
        if (r5 >= r8) goto L_0x0087;
    L_0x0075:
        r8 = r8 - r5;
        r6 = r1.a;
        r5 = r5 + 1;
        r10 = r12.c;
        r6 = (b.p.b.a) r6;
        r6 = r6.h(r9, r5, r8, r10);
        r5 = r12.d;
        r5 = r5 - r8;
        r12.d = r5;
    L_0x0087:
        r2.set(r7, r11);
        r5 = r12.d;
        if (r5 <= 0) goto L_0x0092;
    L_0x008e:
        r2.set(r3, r12);
        goto L_0x009c;
    L_0x0092:
        r2.remove(r3);
        r5 = r1.a;
        r5 = (b.p.b.a) r5;
        r5.k(r12);
    L_0x009c:
        if (r4 == 0) goto L_0x00a1;
    L_0x009e:
        r2.add(r3, r4);
    L_0x00a1:
        if (r6 == 0) goto L_0x0009;
    L_0x00a3:
        r2.add(r3, r6);
        goto L_0x0009;
    L_0x00a8:
        r8 = r11.b;
        r9 = r11.d;
        if (r8 >= r9) goto L_0x00bd;
    L_0x00ae:
        r13 = r12.b;
        if (r13 != r8) goto L_0x00ba;
    L_0x00b2:
        r13 = r12.d;
        r8 = r9 - r8;
        if (r13 != r8) goto L_0x00ba;
    L_0x00b8:
        r5 = 0;
        goto L_0x00c9;
    L_0x00ba:
        r5 = 0;
        r8 = 0;
        goto L_0x00ce;
    L_0x00bd:
        r13 = r12.b;
        r14 = r9 + 1;
        if (r13 != r14) goto L_0x00cc;
    L_0x00c3:
        r13 = r12.d;
        r8 = r8 - r9;
        if (r13 != r8) goto L_0x00cc;
    L_0x00c8:
        r5 = 1;
    L_0x00c9:
        r8 = r5;
        r5 = 1;
        goto L_0x00ce;
    L_0x00cc:
        r5 = 0;
        r8 = 1;
    L_0x00ce:
        r13 = r12.b;
        if (r9 >= r13) goto L_0x00d7;
    L_0x00d2:
        r13 = r13 + -1;
        r12.b = r13;
        goto L_0x00f4;
    L_0x00d7:
        r14 = r12.d;
        r13 = r13 + r14;
        if (r9 >= r13) goto L_0x00f4;
    L_0x00dc:
        r14 = r14 + -1;
        r12.d = r14;
        r11.a = r10;
        r11.d = r4;
        r3 = r12.d;
        if (r3 != 0) goto L_0x0009;
    L_0x00e8:
        r2.remove(r7);
        r3 = r1.a;
        r3 = (b.p.b.a) r3;
        r3.k(r12);
        goto L_0x0009;
    L_0x00f4:
        r4 = r11.b;
        r9 = r12.b;
        if (r4 > r9) goto L_0x00ff;
    L_0x00fa:
        r9 = r9 + 1;
        r12.b = r9;
        goto L_0x0116;
    L_0x00ff:
        r13 = r12.d;
        r9 = r9 + r13;
        if (r4 >= r9) goto L_0x0116;
    L_0x0104:
        r9 = r9 - r4;
        r13 = r1.a;
        r4 = r4 + 1;
        r13 = (b.p.b.a) r13;
        r6 = r13.h(r10, r4, r9, r6);
        r4 = r11.b;
        r9 = r12.b;
        r4 = r4 - r9;
        r12.d = r4;
    L_0x0116:
        if (r5 == 0) goto L_0x0127;
    L_0x0118:
        r2.set(r3, r12);
        r2.remove(r7);
        r3 = r1.a;
        r3 = (b.p.b.a) r3;
        r3.k(r11);
        goto L_0x0009;
    L_0x0127:
        if (r8 == 0) goto L_0x0158;
    L_0x0129:
        if (r6 == 0) goto L_0x0141;
    L_0x012b:
        r4 = r11.b;
        r5 = r6.b;
        if (r4 <= r5) goto L_0x0136;
    L_0x0131:
        r5 = r6.d;
        r4 = r4 - r5;
        r11.b = r4;
    L_0x0136:
        r4 = r11.d;
        r5 = r6.b;
        if (r4 <= r5) goto L_0x0141;
    L_0x013c:
        r5 = r6.d;
        r4 = r4 - r5;
        r11.d = r4;
    L_0x0141:
        r4 = r11.b;
        r5 = r12.b;
        if (r4 <= r5) goto L_0x014c;
    L_0x0147:
        r5 = r12.d;
        r4 = r4 - r5;
        r11.b = r4;
    L_0x014c:
        r4 = r11.d;
        r5 = r12.b;
        if (r4 <= r5) goto L_0x0186;
    L_0x0152:
        r5 = r12.d;
        r4 = r4 - r5;
        r11.d = r4;
        goto L_0x0186;
    L_0x0158:
        if (r6 == 0) goto L_0x0170;
    L_0x015a:
        r4 = r11.b;
        r5 = r6.b;
        if (r4 < r5) goto L_0x0165;
    L_0x0160:
        r5 = r6.d;
        r4 = r4 - r5;
        r11.b = r4;
    L_0x0165:
        r4 = r11.d;
        r5 = r6.b;
        if (r4 < r5) goto L_0x0170;
    L_0x016b:
        r5 = r6.d;
        r4 = r4 - r5;
        r11.d = r4;
    L_0x0170:
        r4 = r11.b;
        r5 = r12.b;
        if (r4 < r5) goto L_0x017b;
    L_0x0176:
        r5 = r12.d;
        r4 = r4 - r5;
        r11.b = r4;
    L_0x017b:
        r4 = r11.d;
        r5 = r12.b;
        if (r4 < r5) goto L_0x0186;
    L_0x0181:
        r5 = r12.d;
        r4 = r4 - r5;
        r11.d = r4;
    L_0x0186:
        r2.set(r3, r12);
        r4 = r11.b;
        r5 = r11.d;
        if (r4 == r5) goto L_0x0193;
    L_0x018f:
        r2.set(r7, r11);
        goto L_0x0196;
    L_0x0193:
        r2.remove(r7);
    L_0x0196:
        if (r6 == 0) goto L_0x0009;
    L_0x0198:
        r2.add(r3, r6);
        goto L_0x0009;
    L_0x019d:
        r4 = r11.d;
        r6 = r12.b;
        if (r4 >= r6) goto L_0x01a5;
    L_0x01a3:
        r5 = -1;
        goto L_0x01a6;
    L_0x01a5:
        r5 = 0;
    L_0x01a6:
        r8 = r11.b;
        if (r8 >= r6) goto L_0x01ac;
    L_0x01aa:
        r5 = r5 + 1;
    L_0x01ac:
        if (r6 > r8) goto L_0x01b3;
    L_0x01ae:
        r6 = r12.d;
        r8 = r8 + r6;
        r11.b = r8;
    L_0x01b3:
        r6 = r12.b;
        if (r6 > r4) goto L_0x01bc;
    L_0x01b7:
        r8 = r12.d;
        r4 = r4 + r8;
        r11.d = r4;
    L_0x01bc:
        r6 = r6 + r5;
        r12.b = r6;
        r2.set(r3, r12);
        r2.set(r7, r11);
        goto L_0x0009;
    L_0x01c7:
        r1 = r0.b;
        r1 = r1.size();
        r2 = 0;
    L_0x01ce:
        if (r2 >= r1) goto L_0x0299;
    L_0x01d0:
        r3 = r0.b;
        r3 = r3.get(r2);
        r3 = (b.p.b.a.b) r3;
        r11 = r3.a;
        if (r11 == r4) goto L_0x0292;
    L_0x01dc:
        if (r11 == r10) goto L_0x023c;
    L_0x01de:
        if (r11 == r9) goto L_0x01e9;
    L_0x01e0:
        if (r11 == r7) goto L_0x01e4;
    L_0x01e2:
        goto L_0x0295;
    L_0x01e4:
        r0.i(r3);
        goto L_0x0295;
    L_0x01e9:
        r11 = r3.b;
        r12 = r3.d;
        r12 = r12 + r11;
        r13 = r11;
        r14 = 0;
        r15 = -1;
    L_0x01f1:
        if (r11 >= r12) goto L_0x0225;
    L_0x01f3:
        r5 = r0.d;
        r5 = (b.p.b.b0) r5;
        r5 = r5.b(r11);
        if (r5 != 0) goto L_0x0213;
    L_0x01fd:
        r5 = r0.a(r11);
        if (r5 == 0) goto L_0x0204;
    L_0x0203:
        goto L_0x0213;
    L_0x0204:
        if (r15 != r4) goto L_0x0211;
    L_0x0206:
        r5 = r3.c;
        r5 = r0.h(r9, r13, r14, r5);
        r0.i(r5);
        r13 = r11;
        r14 = 0;
    L_0x0211:
        r15 = 0;
        goto L_0x0221;
    L_0x0213:
        if (r15 != 0) goto L_0x0220;
    L_0x0215:
        r5 = r3.c;
        r5 = r0.h(r9, r13, r14, r5);
        r0.d(r5);
        r13 = r11;
        r14 = 0;
    L_0x0220:
        r15 = 1;
    L_0x0221:
        r14 = r14 + r4;
        r11 = r11 + 1;
        goto L_0x01f1;
    L_0x0225:
        r5 = r3.d;
        if (r14 == r5) goto L_0x0232;
    L_0x0229:
        r5 = r3.c;
        r0.k(r3);
        r3 = r0.h(r9, r13, r14, r5);
    L_0x0232:
        if (r15 != 0) goto L_0x0238;
    L_0x0234:
        r0.d(r3);
        goto L_0x0295;
    L_0x0238:
        r0.i(r3);
        goto L_0x0295;
    L_0x023c:
        r5 = r3.b;
        r11 = r3.d;
        r11 = r11 + r5;
        r12 = r5;
        r13 = 0;
        r14 = -1;
    L_0x0244:
        if (r12 >= r11) goto L_0x027d;
    L_0x0246:
        r15 = r0.d;
        r15 = (b.p.b.b0) r15;
        r15 = r15.b(r12);
        if (r15 != 0) goto L_0x0265;
    L_0x0250:
        r15 = r0.a(r12);
        if (r15 == 0) goto L_0x0257;
    L_0x0256:
        goto L_0x0265;
    L_0x0257:
        if (r14 != r4) goto L_0x0262;
    L_0x0259:
        r14 = r0.h(r10, r5, r13, r6);
        r0.i(r14);
        r14 = 1;
        goto L_0x0263;
    L_0x0262:
        r14 = 0;
    L_0x0263:
        r15 = 0;
        goto L_0x0272;
    L_0x0265:
        if (r14 != 0) goto L_0x0270;
    L_0x0267:
        r14 = r0.h(r10, r5, r13, r6);
        r0.d(r14);
        r14 = 1;
        goto L_0x0271;
    L_0x0270:
        r14 = 0;
    L_0x0271:
        r15 = 1;
    L_0x0272:
        if (r14 == 0) goto L_0x0278;
    L_0x0274:
        r12 = r12 - r13;
        r11 = r11 - r13;
        r13 = 1;
        goto L_0x027a;
    L_0x0278:
        r13 = r13 + 1;
    L_0x027a:
        r12 = r12 + r4;
        r14 = r15;
        goto L_0x0244;
    L_0x027d:
        r11 = r3.d;
        if (r13 == r11) goto L_0x0288;
    L_0x0281:
        r0.k(r3);
        r3 = r0.h(r10, r5, r13, r6);
    L_0x0288:
        if (r14 != 0) goto L_0x028e;
    L_0x028a:
        r0.d(r3);
        goto L_0x0295;
    L_0x028e:
        r0.i(r3);
        goto L_0x0295;
    L_0x0292:
        r0.i(r3);
    L_0x0295:
        r2 = r2 + 1;
        goto L_0x01ce;
    L_0x0299:
        r1 = r0.b;
        r1.clear();
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: b.p.b.a.j():void");
    }

    public void k(b bVar) {
        bVar.c = null;
        this.a.b(bVar);
    }

    public void l(List<b> list) {
        int size = list.size();
        for (int i = 0; i < size; i++) {
            k((b) list.get(i));
        }
        list.clear();
    }

    public final int m(int i, int i2) {
        for (int size = this.c.size() - 1; size >= 0; size--) {
            b bVar = (b) this.c.get(size);
            int i3 = bVar.a;
            int i4;
            if (i3 == 8) {
                int i5;
                i4 = bVar.b;
                i3 = bVar.d;
                int i6;
                if (i4 < i3) {
                    i5 = i4;
                    i6 = i3;
                } else {
                    i6 = i4;
                    i5 = i3;
                }
                if (i < i5 || i > i6) {
                    if (i < i4) {
                        if (i2 == 1) {
                            bVar.b = i4 + 1;
                            bVar.d = i3 + 1;
                        } else if (i2 == 2) {
                            bVar.b = i4 - 1;
                            bVar.d = i3 - 1;
                        }
                    }
                } else if (i5 == i4) {
                    if (i2 == 1) {
                        bVar.d = i3 + 1;
                    } else if (i2 == 2) {
                        bVar.d = i3 - 1;
                    }
                    i++;
                } else {
                    if (i2 == 1) {
                        bVar.b = i4 + 1;
                    } else if (i2 == 2) {
                        bVar.b = i4 - 1;
                    }
                    i--;
                }
            } else {
                i4 = bVar.b;
                if (i4 <= i) {
                    if (i3 == 1) {
                        i -= bVar.d;
                    } else if (i3 == 2) {
                        i += bVar.d;
                    }
                } else if (i2 == 1) {
                    bVar.b = i4 + 1;
                } else if (i2 == 2) {
                    bVar.b = i4 - 1;
                }
            }
        }
        for (i2 = this.c.size() - 1; i2 >= 0; i2--) {
            b bVar2 = (b) this.c.get(i2);
            if (bVar2.a == 8) {
                int i7 = bVar2.d;
                if (i7 == bVar2.b || i7 < 0) {
                    this.c.remove(i2);
                    k(bVar2);
                }
            } else if (bVar2.d <= 0) {
                this.c.remove(i2);
                k(bVar2);
            }
        }
        return i;
    }
}
